﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FinModel
{
    public static class Rate
    {
        /// <summary>
        /// annualized percentage yield
        /// </summary>
        /// <returns></returns>
        public static double APY(double r, double n)
        {
            return Math.Pow(1 + r, n) - 1;
        }
        /// <summary>
        /// annualized percentage rate
        /// </summary>
        /// <returns></returns>
        public static double APR(double r, double n)
        {
            return r * n;
        }
        /// <summary>
        /// continuous compounding rate
        /// </summary>
        /// <param name="r"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static double ContCR(double r, double n)
        {
            return Math.Pow(Math.E, r * n);
        }
        /// <summary>
        /// continuous discounting rate
        /// </summary>
        /// <param name="r"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static double ContDR(double r, double n)
        {
            return Math.Pow(Math.E, -r * n);
        }
    }
}
